package com.systemsjr.jrappointment;

import org.springframework.richclient.command.ActionCommand;
import org.springframework.richclient.command.CommandGroup;

import com.systemsjr.jrappointment.appointment.command.AppointmentsCommand;
import com.systemsjr.jrappointment.customer.command.CustomersCommand;
import com.systemsjr.jrappointment.invoice.command.InvoicesCommand;
import com.systemsjr.jrappointment.service.command.ServicesCommand;
import com.systemsjr.jrappointment.setting.command.SettingsCommand;
import com.systemsjr.jrappointment.user.command.UsersCommand;
import com.systemsjr.jrlib.richclient.BaseItemView;

public class ApplicationView extends BaseItemView {
	
	private ActionCommand usersCommand;
	private ActionCommand appointmentsCommand;
	private ActionCommand servicesCommand;
	private ActionCommand invoicesCommand;
	private ActionCommand settingsCommand;
	private ActionCommand customersCommand;
	
	public ApplicationView(){
		this("applicationView");
	}

	public ApplicationView(String string) {
		super(string);
	}
	
	public ActionCommand getUsersCommand(){
		
		if(usersCommand == null){
			usersCommand = new UsersCommand();
		}
		
		return usersCommand;
	}

	public ActionCommand getAppointmentsCommand() {
		
		if(appointmentsCommand == null){
			appointmentsCommand = new AppointmentsCommand();
		}
		
		return appointmentsCommand;
	}

	public ActionCommand getServicesCommand() {
		if(servicesCommand == null){
			servicesCommand = new ServicesCommand();
		}
		return servicesCommand;
	}

	public ActionCommand getInvoicesCommand() {
		
		if(invoicesCommand == null){
			invoicesCommand = new InvoicesCommand();
		}
		return invoicesCommand;
	}

	public ActionCommand getSettingsCommand() {
		
		if(settingsCommand == null){
			settingsCommand = new SettingsCommand();
		}
		return settingsCommand;
	}

	public ActionCommand getCustomersCommand() {
		if(customersCommand == null){
			customersCommand = new CustomersCommand();
		}
		return customersCommand;
	}

	@Override
	public void addTasks() {
		CommandGroup applicationGroup = CommandGroup.createCommandGroup(new ActionCommand[]{
				getAppointmentsCommand(),
				getServicesCommand(),
				getCustomersCommand(),
				getInvoicesCommand(),
				getUsersCommand(),
				getSettingsCommand()
		});
		
		taskPane.setTitle("Menu");
		taskPane.add(applicationGroup.createButtonStack());
	}

}
